#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__

#include "cocos2d.h"
#include "ADUBrick.h"
#include "ADUConstant.h"
#include "ADUGameManager.h"
#include "ADUInfiniteParallaxNode.h"
#include "extensions/cocos-ext.h"
#include "ui/CocosGUI.h"

USING_NS_CC;
USING_NS_CC_EXT;
using namespace ui;

class BrickSprite;
class MainLayer : public cocos2d::Layer
{
public:
    // there's no 'id' in cpp, so we recommend returning the class instance pointer
    static cocos2d::Scene* createScene();

    // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
    virtual bool init();  
    
    
    // implement the "static create()" method manually
    CREATE_FUNC(MainLayer);
	void update(float dt);

	
	bool onTouchBegan(Touch*, Event*);
	void onTouchMoved(Touch*, Event*);
	void onTouchEnded(Touch*, Event*);
	void onTouchCancelled(Touch*, Event*);

	void initParameters();
	void createParticleFire(float x,float y);
	void createParticleWater(float x,float y);
	void setEmitterPosition(ParticleSystemQuad* particle, float x, float y);
	void drawCircle();
	void createBricks();
	void createStars();
	void createExplodingRing(const Vec2& pos);
	void createGalaxy();
	void showGameOver();
	void hideObject(Node* node);
	void hideBrick();
	void showBrick(); // reset
private:
	Sprite* 		_circleFire;
	Sprite* 		_circleWater;
	Sprite* 		_center;
	float			_speedRotate;
	float			_gravity;
	float 			_direction;
	float			_centerX, _centerY;
	float			_radius;
	bool			_move;
	float			_angle;
	DrawNode* 		_draw;
	BrickSprite* 	_brick[NUM_BRICK];
	EventListenerTouchOneByOne* _listener;
	ParticleSystemQuad* 		_emitterFire;
	ParticleSystemQuad*			_emitterWater;
	ParticleSystemQuad*    		_emitterStar;
	ParticleSystemQuad*    		_emitterRing;
	ParticleSystemQuad*			_emitterGalaxy;
	InfiniteParallaxNode*		_backgroundElements ;
	Text*			_scoreText;
	char  			_score[5], _scoreTextGO[5], _bestScoreTextGO[5]; // Leak
	bool			_startGame, _restartGame;
	Text*			_titleGame;
	Text*			_goText;

	Text*			_scoreGameOver;
	Text*			_bestScoreGameOver;
	Vec2			_posGo, _posScore, _posScoreGameOver, _posBestScoreGameOver;
	Vec2			_posDraft;
	
};

#endif // __HELLOWORLD_SCENE_H__
